//    Copyright (C) Kherty.  All rights reserved.
using System.Collections.Generic;
using System.Diagnostics.Contracts;

namespace OpenLS.Spreadsheet.Expressions
{
    abstract class UnaryExpressionBase : Expression
    {
        internal Expression Inner { get
        {
            Contract.Ensures(Contract.Result<Expression>() != null);
            return _inner;
        } }
        private readonly Expression _inner;

        protected UnaryExpressionBase(Expression inner)
        {
            _inner = inner;
        }

        public override IEnumerable<Expression> GetSubExpressions()
        {
            yield return Inner;
        }

        public override IEnumerable<IDependencyNode> GetPrecedents(EvaluationContext context)
        {
            return Inner.GetPrecedents(context);
        }
    }
}